package com.jl.sms.userdata.IE;

import com.jl.sms.userdata.ShortMessage;

public class SIMToolkitSecurityHeaders implements InformationElement{
	
	private byte[] resData;
	private ShortMessage sm;
	private byte id;
	
	public SIMToolkitSecurityHeaders(ShortMessage sm, byte id){
		this.sm = sm;
		this.id = id;
		if(sm.headerLength() == 0){
			resData = new byte[sm.value().length + 3];
		}else{
			resData = new byte[sm.value().length + 2];
		}
		resData[0] = (byte) (0x02 + sm.headerLength());
		resData[1] = id;
		resData[2] = 0x00;
		int index = sm.headerLength() == 0 ? 0 : 1;
		System.arraycopy(sm.value(), index , resData, 3, sm.value().length - index);
	}
	
	public SIMToolkitSecurityHeaders(ShortMessage sm){
		this(sm, (byte) 0x70);
	}


	@Override
	public byte[] value() {
		return resData;
	}


	@Override
	public byte getID() {
		return id;
	}


	@Override
	public int headerLength() {
		return sm.headerLength() + 2;
	}

}
